package com.xuecheng.content.controller;

import com.xuecheng.api.content.model.api.CourseTeacherApi;
import com.xuecheng.api.content.model.vo.CourseTeacherVO;

import com.xuecheng.content.common.util.UAASecurityUtil;
import com.xuecheng.content.service.CourseTeacherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 课程-教师关系表 前端控制器
 * </p>
 *
 * @author itcast
 */
@Slf4j
@RestController
@RequestMapping
public class CourseTeacherController implements CourseTeacherApi {

    @Autowired
    private CourseTeacherService  courseTeacherService;

    @Override
    @GetMapping("/courseTeacher/list/{courseBaseId}")
    public List<CourseTeacherVO> queryTeachersByCourseId(@PathVariable Long courseBaseId) {

        Long companyId = UAASecurityUtil.getCompanyId();
        return courseTeacherService.queryTeachersByCourseId(courseBaseId,companyId);
    }

    @Override
    @PostMapping("/courseTeacher")
    public CourseTeacherVO createOrModifyTeacher(@RequestBody CourseTeacherVO vo) {
        Long companyId = UAASecurityUtil.getCompanyId();
        return courseTeacherService.createOrModifyTeacher(vo,companyId);
    }

    @Override
    @DeleteMapping("/courseTeacher/course/{courseId}/{courseTeacherId}")
    public void removeTeacher(@PathVariable Long courseId, @PathVariable Long courseTeacherId) {
        Long companyId = UAASecurityUtil.getCompanyId();

         courseTeacherService.removeTeacher(courseId,courseTeacherId,companyId);
    }

//    @GetMapping("/courseTeacher/list/{courseBaseId}")


}
